#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int x = ((b - a)/c + 1);
	int y = a + b;
	printf("%d",x*y/2);
	return 0;
}
